import {BasicColumn, FormSchema} from '/@/components/Table';
import moment from 'moment';

export const columns: BasicColumn[] = [
    {
        title: '日志ID',
        dataIndex: 'id',
        width: 60,
    },
    {
        title: '用户ID',
        dataIndex: 'user_id',
        width: 60,
    },
    {
        title: '操作对象',
        dataIndex: 'object_cls',
        width: 80,
    },
    {
        title: '操作方法',
        dataIndex: 'method',
        width: 100,
    },
    {
        title: 'IP地址',
        dataIndex: 'ip',
        width: 200,
    },
    {
        title: '备注',
        dataIndex: 'remark',
        width: 180,
    },
    {
        title: '操作时间',
        dataIndex: 'createTime',
        width: 180,
        format: (text: string) => moment(text).format('YYYY-MM-DD HH:mm:ss'),
    },
];

export const searchFormSchema: FormSchema[] = [
    {
        field: 'user_id',
        label: '用户ID',
        component: 'Input',
        colProps: {xl: 8, lg: 12},
    },
    {
        field: 'object_cls',
        label: '操作对象',
        component: 'Input',
        colProps: {xl: 8, lg: 12},
    },
    {
        field: 'method',
        label: '操作方法',
        component: 'Input',
        colProps: {xl: 8, lg: 12},
    },
    {
        field: 'ip',
        label: 'IP地址',
        component: 'Input',
        colProps: {xl: 8, lg: 12},
    },
    {
        field: 'createTime',
        label: '操作时间',
        component: 'RangePicker',
        colProps: {xl: 8, lg: 12},
        componentProps: {
            allowClear: true,
            showTime: true
        }
    },

];

export const logsFormSchema: FormSchema[] = [
    {
        field: 'id',
        label: 'ID',
        component: 'Input',
        show: false
    },
    {
        field: 'user_id',
        label: '用户ID',
        component: 'Input',
        componentProps: {
            autoSize: true,
            allowClear: false
        }
    },
    {
        field: 'object_cls',
        label: '操作对象',
        component: 'Input',
        componentProps: {
            autoSize: true,
            allowClear: false
        }
    },
    {
        field: 'method',
        label: '操作方法',
        component: 'Input',
        componentProps: {
            autoSize: true,
            allowClear: false
        }
    },

    {
        field: 'ip',
        label: 'IP地址',
        component: 'Input',
        componentProps: {
            autoSize: true,
            allowClear: false
        }
    },

    {
        field: 'createTime',
        label: '操作时间',
        component: 'Input',
        componentProps: {
            autoSize: true,
            allowClear: false
        }
    },
    {
        label: '备注',
        field: 'remark',
        component: 'InputTextArea',
        componentProps: {
            autoSize: true,
            allowClear: false
        }
    },
    {
        label: '详情',
        field: 'detail',
        component: 'InputTextArea',
        componentProps: {
            autoSize: true,
            allowClear: false
        },
        // render: ({model, field}) => {
        //     const text = JSON.stringify(model[field])
        //     return h(Textarea, {
        //         value: text,
        //         autoSize: true,
        //     });
        // },
    },
];

